package com.tuocent.dagv2.controller;

import com.tuocent.dagv2.common.AjaxResult;
import com.tuocent.dagv2.entity.ArchivesReceive;
import com.tuocent.dagv2.service.IArchivesReceiveService;
import com.tuocent.dagv2.service.IWorkflowService;
import jakarta.servlet.http.HttpSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

import java.util.Map;


/**
 * 数字化工作流
 *
 */

@Controller
@RequestMapping("workflow")
public class WorkflowController {
    @Autowired
    private IArchivesReceiveService archivesReceiveService;
    @Autowired
    private IWorkflowService workflowService;

    @GetMapping("archivesReceive")
    public String archivesReceive(Model model) {
        return archivesReceiveService.archivesReceive(model);
    }

    @RequestMapping("getArchivesReceiveData")
    @ResponseBody
    public AjaxResult getArchivesReceiveData(@RequestBody Map<String, Object> params) {
        return archivesReceiveService.getArchivesReceiveData(params);
    }

    @GetMapping("setArchivesReceive")
    public String setArchivesReceive(Model model,
                                     @RequestParam("pid") String pid,
                                     @RequestParam("tid") String tid,
                                     @RequestParam("id") String id) {
        return archivesReceiveService.setArchivesReceive(model, pid, tid, id);
    }

    @RequestMapping("saveArchivesReceiveData")
    @ResponseBody
    public AjaxResult saveArchivesReceiveData(HttpSession session, @RequestBody ArchivesReceive data) {
        return archivesReceiveService.saveArchivesReceiveData(session, data);
    }


    @RequestMapping("delArchivesReceive")
    @ResponseBody
    public AjaxResult delArchivesReceive(HttpSession session, @RequestBody Map<String, Object> params) {
        return archivesReceiveService.delArchivesReceive(session, params);
    }

    @GetMapping("arrangement")
    public String arrangement(Model model) {
        return workflowService.arrangement(model);
    }
}
